<%@page import="me.whf.model.Employee"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.servlet.http.HttpSession;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui.js"></script>
	<link rel="stylesheet" href="css/jquery-ui.css"/>
	<link rel="stylesheet" href="css/bootstrap.css">
	<link rel="stylesheet" href="css/navbar.css"/>
	<title>银行管理系统</title>
</head>
<body>
	<div class="navbar">
		<div class="navbar_container">
			<ul>
				<li id="bar_1" class="hover"><a onclick="navigate(1)">产生总报表</a></li>
				<li id="bar_2"><a onclick="navigate(2)">添加银行雇员</a></li>
			</ul>
			<ul>
				<li id="exit" class="exit"><a id="logout">退出</a></li>
			</ul>
		</div>
	</div>
	<% String username = ((Employee)session.getAttribute("employee")).getUsername(); %>
	<center><h3>欢迎：<%= username %></h3></center>
	<div id="panel">
		<form id="panel_1" class="hover">
			<table class="centerTable1">
				<tr>
					<td>开始日期：</td>
					<td><input type="text" id="createlog_start_date"></td>
				</tr>
				<tr>
					<td>结束日期：</td>
					<td><input type="text" id="createlog_end_date"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td align="right"><input type="button" id="log_enter" class="btn btn-primary" value="产生报表"></td>
				</tr>
			</table>
		</form>
		<form id="panel_2" style="display:none">
			<table class="centerTable2">
				<tr>
					<td>雇员ID：</td>
					<td><input type="text" id="register_employeeID" size="15"></td>
				</tr>
				<tr>
					<td>密码：</td>
					<td><input type="password" id="register_password" size="15"></td>
				</tr>
				<tr>
					<td>密码确认：</td>
					<td><input type="password" id="register_password_confirm" size="15"></td>
				</tr>
				<tr>
					<td>用户名： </td>
					<td><input type="text" id="register_username" size="15"></td>
				</tr>
				<tr>
					<td>部门ID：</td>
					<td><input type="text" id="register_apartmentID" size="15"></td>
				</tr>
				<tr>
					<td>雇员类型：</td>
					<td align="right">
						<select id="register_employeeType">
					 		<option value="RECEPTION">前台操作员</option>
					 		<option value="MANAGER">银行经理</option>
					 		<option value="HEADMANAGER">银行业务总管</option>
					 		<option value="ADMINISTRATOR">系统管理员</option>
					 	</select>
					 </td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td align="right"><input type="button" class="btn btn-primary" id="register_enter" value="注册雇员"></td>
				</tr>
			</table>
		</form>
	</div>
</body>


<script type="text/javascript">
	function navigate(index) {
		for (var i = 1; i <= 2; i++) {
			var navigationBar = document.getElementById("bar_" + i);
			var panel = document.getElementById("panel_" + i);
			navigationBar.className = i == index? "hover": "";
			panel.style.display = i == index? "block": "none";
		}
		document.getElementById("panel_1").reset();
		document.getElementById("panel_2").reset();
		centralization();
	}
	function centralization() {
		var tabletop = 200;
		if (($(window).height() - $(".centerTable" + i).outerHeight()) / 2 < 64)
			tabletop = 64;
		for (var i = 1; i <= 2; i++) {
			$(".centerTable" + i).css({
				position: "absolute",
				left: ($(window).width() - $(".centerTable" + i).outerWidth()) / 2,
				top: tabletop
			});
		}
	}
	$(function() {
		centralization();
		$(window).resize(function (){
			centralization();
		});
		$("#logout").click(function () {
			$.ajax({
				url: "index",
				type: "post",
				dataType: "text",
				data:{
					action: "LOGOUT"
				},
				success: function (data) {
					alert(data);
					location.href = "index.jsp";
				}
			});
		});
		$("#createlog_start_date").datepicker();
		$("#createlog_end_date").datepicker();
		$("#log_enter").click(function () {
			$.ajax({
				url: "administrator",
				type: "post",
				dataType: "text",
				data: {
					startDate: $("#createlog_start_date").val(),
					endDate: $("#createlog_end_date").val(),
					action: "LOG"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#register_enter").click(function () {
			var password = $("#register_password").val();
			var passwordConfirm = $("#register_password_confirm").val();
			if (password != passwordConfirm) {
				alert("密码输入不一致");
				return;
			}
			$.ajax({
				url: "administrator",
				type: "POST",
				dataType: "text",
				data: {
					employeeID: $("#register_employeeID").val(),
					password: $("#register_password").val(),
					username: $("#register_username").val(),
					apartmentID: $("#register_apartmentID").val(),
					employeeType: $("#register_employeeType").val(),
					action: "REGISTER"
				},
				success: function (data) {
					r = confirm(data);
					
					if (data != "用户已存在" && (r == true || r == false)) {
						if (data.substring(8) == "ADMINISTRATOR")
							location.href = "administrator.jsp";
						else
							location.href = "employee.jsp";
					}
				}
			});
		});
	});
	</script>
</html>